#include <bits/stdc++.h>
using namespace std;

const int N = 200005;

typedef pair<int, int> PII;

int n;
vector<PII> a;
int q[N];

int main()
{
	freopen("fruit.in", "r", stdin);
	freopen("fruit.out", "w", stdout);

	scanf("%d", &n);
	
	for (int i = 1, u; i <= n; i++)
	{
		scanf("%d", &u);
		a.push_back({u, i});
	}
		
	while (!a.empty())
	{
		int hh = 0, tt = -1, num = 0x3f3f3f3f;
		
		for (int i = 0; i < a.size(); i++)
		{
			int j = i;
			while (a[j].first == a[i].first && j < a.size())
				j++;
				
			num = min(num, j - i);
			
			q[++tt] = a[i].second;
			
			i = j - 1;
		}
		
		for (int i = 0; i < a.size(); i++)
		{
			int j = i;
			while (a[j].first == a[i].first && j < a.size())
				j++;
			
			for (int k = 0; k < num; k++)
				a.erase(a.begin() + i + k);
				
			i = j - 1;
		}
		
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j <= tt; j++)
			{
				printf("%d ", q[j] + i);
			}
			puts("");
		}
	}
	
	return 0;
}
